package com.passgen;


import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class PasswordGeneratorUtils {
    public static final String A_TO_Z = "abcdefghigklmnopqrstuvwzyz";
    public static final String DIGITS = "0123456789";
    public static final String ANSI = "!@#$%^&*()_+[]{}";


    public enum CharList {
        DIGITS,
        DIGITS_LOWERCASE,
        DIGITS_LETTERS,
        ANSI;
        public static final String A_TO_Z = "abcdefghigklmnopqrstuvwzyz";

        public String getValue() {
            switch(this) {
                case DIGITS:
                    return "0123456789";
                case DIGITS_LOWERCASE:
                    return DIGITS.getValue() + A_TO_Z;
                case DIGITS_LETTERS:
                    return DIGITS.getValue() + A_TO_Z + A_TO_Z.toUpperCase();
                case ANSI:
                    return "0123456789abcdefghigklmnopqrstuvwzyzABCDEFGHIGKLMNOPQRST!@#$%^&*()_+";
            }
            throw new IllegalArgumentException(this + " should be defined!");
        }

        public static Map<String, CharList> createFiltersMap() {
             Map<String, CharList> map = new HashMap<String, CharList>();
             for (CharList charList : CharList.values()) {
                 map.put(charList.getValue(), charList);
             }
            return map;
        }





        @Override
        public String toString() {
            switch (this) {
                case DIGITS:
                    return "Digits";
                case DIGITS_LOWERCASE:
                    return "Digits and lowercase letters";
                case DIGITS_LETTERS:
                    return "Digits and letters";
                case ANSI:
                    return "ANSI";
            }
            throw new IllegalArgumentException(this + " must be defined!");
        }
    }




    public static String randomString(final int length, String charList) {
        Random random = new Random(System.currentTimeMillis());
        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < length; i++) {
            int position = random.nextInt(charList.length()-1);
            stringBuilder.append(charList.charAt(position));
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {




    }
}
